<?

//Initiate Authenticate
SecurityRedirect ();

//initiate Vars
define("PRIMARY_KEY","tariff_id");
$KEY[]         = array("PRIMARY_KEY"=>PRIMARY_KEY);
$FileName      = "ais_transaction_tarifflist.php";
$FormName            = GetParam("FormName","");
$urut            = GetParam("urut","");
$debtur            = GetParam("debtur","");
$FileTemplate  = "ais_transaction_tarifflist_jobsliptruck_list.html";

$SubHeaderTitle = "Tariff List Job Slip Truck";
$PageSize      = 10 ;
$HTMLGridList  = "TariffGrid";
//************ FORM ACTION **************
    if (GetParam("Action","")=="Delete") {
        DeleteRecord ("txtCheck",$PageSize);
    }

//Initiate Database Table For Search;
$tariff_code = GetParam("tariff_code","");
$tariff_desc = GetParam("tariff_desc","");
$need_another_var = GetParam("need_another_var","");

//******* DATABASE FORM QUERY ***********


$SQL = " SELECT * FROM tbltariff ";


if ($tariff_code)
    if (strlen($WHERE)) $WHERE .= " AND "." tariff_code like '%".$tariff_code."%'";
    else $WHERE .= " tariff_code like '%".$tariff_code."%'";

if ($tariff_desc)
    if (strlen($WHERE)) $WHERE .= " AND "." tariff_desc like '%".$tariff_desc."%'";
    else $WHERE .= " tariff_desc like '%".$tariff_desc."%'";

if (strlen($WHERE)) $WHERE = " WHERE ".$WHERE;
    else $WHERE = " WHERE 1 ";

$SQL = $SQL.$WHERE." ORDER BY tariff_id DESC ";



//echo "$SQL";

$WHERE="";

$SQLCount = " SELECT count(*) FROM tbltariff ";


if ($tariff_code)
    if (strlen($WHERE)) $WHERE .= " AND "." tariff_code like '%".$tariff_code."%'";
    else $WHERE .= " tariff_code like '%".$tariff_code."%'";

if ($tariff_desc)
    if (strlen($WHERE)) $WHERE .= " AND "." tariff_desc like '%".$tariff_desc."%'";
    else $WHERE .= " tariff_desc like '%".$tariff_desc."%'";

if (strlen($WHERE)) $WHERE = " WHERE ".$WHERE;
    else $WHERE = " WHERE 1 ";

$SQLCount = $SQLCount.$WHERE." ORDER BY tariff_id DESC ";



//Select Department


//******* SHOW FORM CONTENT *********
$PageNum = 1;
$RecCnt = $DBConnection->dbc->get_var($SQLCount) ;

if (GetParam("PageNum","")) $PageNum  = GetParam("PageNum","");

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate($MOD_TEMPLATE_DIR."/".$FileTemplate);
$TBS->MergeBlock("bln",$KEY);
$TBS->MergeBlock("blg",$DBMysql,$SQL,$PageSize,$PageNum,$RecCnt);

$TBS->MergeNavigationBar('nv',array('size'=>10,'pos'=>'centred'),$PageNum,$RecCnt,$PageSize) ;
$TBS->Show();


function DeleteRecord ($sequence_name,$PageSize) {
    global $DBConnection,$FileName;
    for ($x=1;$x<=$PageSize;$x++) {
        if (GetParam($sequence_name.$x,"")) {
            $DBConnection->Delete("tblstaff",$sequence_name.$x);
        }
    }
    header("Location: $FileName");
    exit;

}

?>
